home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1993 May / Info-Mac_II_May_1993.to_.sit / Info-Mac II (May 1993).toast / Technical / Compactor File Format.txt < prev    next >
Internet Message Format  |  1992-08-29  |  8KB

  1. Date: Sun, 14 Apr 91 12:45:25 EDT
  2. From: Johnny Lee <jlee@watnow.waterloo.edu>
  3. Subject: Compactor file format...
  4.  
  5.  
  6. A few people keep posting questions on this.
  7. By examining the files Compact Pro produces
  8. I was able to discern the file format which corresponds very
  9. well to the file format which Compactor's authour send out to
  10. developers.
  11.  
  12. I thought you might want the file containing the file format.
  13. It contains the file format description as given by Compactor's
  14. authour and by me. It doessn't contain info on how to extract
  15. files from Compact Pro archives.
  16. If you decide not to, that's fine with me.
  17.  
  18. Sorry about the first desciption (from Compact Pro's authour).
  19.  
  20. Johnny
  21.  
  22. =======================================================================
  23. Date:  25-Jul-90 09:56 CDT
  24. >From:  Bill Goodman [71101,204]
  25. Subj:  file format
  26.  
  27. Here is the information for accessing the directory information in
  28. Compactor archives which I have distributed to other developers.
  29.  
  30. ----------------------------------------------------------------------------
  31. -
  32.  
  33. One complication with Compactor archives is that they can be segmented to
  34. span
  35. multiple disks.  Each segment is a standard Macintosh file; however, you
  36. may
  37. need to give them special treatment.  I believe that the only segment which
  38. will be of interest to you is the last one, because it is the one that
  39. contains the directory for the archive.
  40.  
  41. Each segment begins with a segment header (DiskSegHeader).  The dirOffset
  42. field gives you the offset of the directory in the file.  If this is part
  43. of a
  44. multi-segment archive and this is not the last segment, dirOffset will be
  45. 0.
  46. You should skip these files since they do not contain any directory
  47.  
  48.  
  49. Enter command or <CR> for more!
  50.  
  51. CompuServe Mail
  52.  
  53. information.
  54.  
  55. Using dirOffset you can read the directory header (DiskDirHeader).  Note
  56. that
  57. the directory header is of variable length due to the archive note.  You
  58. must
  59. determine where the directory header ends because the first file/folder
  60. record
  61. begins immediately after the directory header.  The number of file/folder
  62. records which follow is given by recordCnt.
  63.  
  64. File records (DiskFileRec) and folder records (DiskFolderRec) are also
  65. variable length because the file/folder names are stored as the minimum
  66. length
  67. Pascal string.  Special encoding of the first character of the file/folder
  68. name allows you to determine whether the following record is file record or
  69. a
  70. folder record.  If the first byte (the string length) is less than 128, the
  71. record is a file record.  If the first byte is greater than 128, the record
  72. is
  73. a folder record.  Note that the length byte for the folder name string must
  74. be
  75. adjusted (by subtracting 128) to obtain the correct length of the folder
  76. name.
  77.  
  78. I believe the fields in the file records should be self explanatory;
  79. however,
  80. the recordCnt field in the folder record requires a little more
  81. description.
  82.  
  83.  
  84. Enter command or <CR> for more!
  85.  
  86. CompuServe Mail
  87.  
  88. The recordCnt field indicates the total number of following records which
  89. are
  90. included in this folder - this includes both file and folder records.  To
  91. illustrate, here is a small example with the recordCnt numbers supplied in
  92. parentheses:
  93.  
  94. Dog folder (10)
  95.      File1
  96.      File2
  97.      Cat folder (2)
  98.         File3
  99.         File4
  100.      Moose folder (3)
  101.         File5
  102.         File6
  103.         File7
  104.      File8
  105. File9
  106. Empty folder (0)
  107. File10
  108.  
  109.  
  110. Enter command or <CR> for more!
  111.  
  112. CompuServe Mail
  113.  
  114.  
  115. ------------------
  116.  
  117. typedef struct
  118.    {
  119.    unsigned char fileFormat;     /* File format version code (1) */
  120.    unsigned char segNum;         /* Segment number */
  121.    unsigned int arcID;           /* Randomly generated archive ID number */
  122.    unsigned long int dirOffset;  /* Offset of directory in this segment */
  123.    } DiskSegHeader;
  124.  
  125. typedef struct
  126.    {
  127.    unsigned char filler[4];   /* CRC for directory */
  128.    int recordCnt;             /* Number of file/folder records in dir */
  129.    unsigned char arcNote[n];  /* Archive note (Pascal string, n = 1 - 256)
  130. */
  131.    } DiskDirHeader;
  132.  
  133. typedef struct
  134.  
  135.  
  136. Enter command or <CR> for more!
  137.  
  138. CompuServe Mail
  139.  
  140.    {
  141.    unsigned char fName[n];         /* File name (Pascal string, n = 1 - 32)
  142. */
  143.    unsigned char filler[5];
  144.    OSType fileType;                /* File type */
  145.    OSType fileCreator;             /* File creator */
  146.    unsigned long int createDate;   /* Creation date */
  147.    unsigned long int lastModDate;  /* Last modification date */
  148.    unsigned char filler[8];
  149.    unsigned long rForkLen;         /* Length of resource fork */
  150.    unsigned long dForkLen;         /* Length of data fork */
  151.    unsigned char filler[8];
  152.    } DiskFileRec;
  153.  
  154. typedef struct
  155.    {
  156.    unsigned char fName[n];   /* Folder name (Pascal string, n = 1 - 32) */
  157.    int recordCnt;            /* Number of records contained in this folder
  158. */
  159.    } DiskFolderRec;
  160.  
  161.  
  162.  
  163. ==============================================================================
  164.  
  165. January 9, 1991
  166.  
  167. Compactor file format (as far as I've been able to discern)
  168. ===========================================================
  169.  
  170. Archive structure
  171. -----------------
  172.  
  173. A Compactor archive contains an Archive Header(AH) followed
  174. by the compressed data followed by the Table of Contents (TOC).
  175.  
  176. <Archive Header> :
  177.     1 byte      - always 1, probably version number
  178.     1 byte      - number of segments in this archive, i.e. 0-255
  179.     2 bytes     - ???
  180.     4 bytes     - location of TOC; always at the end of an archive,
  181.                   i.e. will be in the last segment of a multi-
  182.                        segment archive, otherwise 0.
  183.  
  184. The TOC refers to information about the directories and files
  185. in the archive.
  186.  
  187. <Table of Contents header> :
  188.     4 bytes     - CRC for directory
  189.     2 bytes     - number of files and folders in the TOC
  190.     1 byte      - length (LEN) of "Note" text
  191.     LEN bytes   - actual "Note" text, if LEN == 0, no bytes
  192.  
  193.     <...followed by directory and file structures...>
  194.  
  195. =========================>> NOTE 1 <<===============================
  196. The following structures are never guaranteed to be aligned to
  197. word or long word boundaries in the archive, so you'll have
  198. to read them into an appropriate structure as opposed to using a
  199. pointer to the data.
  200. ====================================================================
  201.  
  202. =========================>> NOTE 2 <<===============================
  203. Remember that directory and file names will always be less than 128
  204. characters (31 chars max, I believe).
  205. ====================================================================
  206.  
  207. If a directory exists in the archive, it will be of this form
  208. <Directory Structure>:
  209.     1 byte      - length (LEN) of directory name (high bit will be set)
  210.     LEN bytes   - directory name text
  211.     2 bytes     - number of files/folders(NFF) in this directory, followed by
  212.                   NFF File and Directory structures.
  213.  
  214. If a file exists in the archive, it will be of this form
  215. <File Structure>:
  216.     1 byte      - length (LEN) of file name (high bit will not be set)
  217.     LEN bytes   - file name text
  218.     1 byte      - seems to always be 1, though I don't really know why yet
  219.     4 bytes     - offset from start of file for file's compressed data
  220.     4 bytes     - Mac File Type
  221.     4 bytes     - Mac File Creator
  222.     4 bytes     - file creation time (I assume, in secs. since Jan1, 1904)
  223.     4 bytes     - file modification time
  224.     4 bytes     - checksum? (one for resource and one for data fork?)
  225.     4 bytes     - checksum? (could try all the popular CRC algorithms to see
  226.                              if anything matches)
  227.     4 bytes     - original resource fork length
  228.     4 bytes     - original data fork length
  229.     4 bytes     - compressed resource fork length
  230.     4 bytes     - compressed data fork length
  231.  
  232. =========================>> NOTE 3 <<===============================
  233. My guess as to compression is that Compactor uses a variant of Limpel-Ziv
  234. compression similar to that of Unix Compress & Stuffit 1.5.1 as opposed
  235. to the Limpel-Ziv variant used in LHarc.
  236. Anyone willing to tell me what it is?
  237. ====================================================================
  238.  
  239. =========================>> NOTE 4 <<===============================
  240. Encryption seems to add about eight bytes to the size of a file's
  241. compressed data.
  242. ====================================================================
  243.  
  244.